// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import FSMState from "../FSM/FSMState";
import Input from "../common/Input";

const {ccclass, property} = cc._decorator;

@ccclass
export default class Idle extends FSMState {

    anim: string = 'down_idle';

    start() {

    }

    // 进入状态
    onEnter() {
        super.onEnter();

        // console.log(`IDLE:${Input.Instance.keyCode}`)

        switch (Input.Instance.keyCode) {
            case cc.macro.KEY.w:
                this.anim = 'up_idle';
                break;
            case cc.macro.KEY.a:
                this.anim = 'left_idle';
                break;
            case cc.macro.KEY.s:
                this.anim = 'down_idle';
                break;
            case cc.macro.KEY.d:
                this.anim = 'right_idle';
                break;
        }
        this.component.getComponent(cc.Animation).play(this.anim);
    }

    // 状态更新中
    onUpdate(dt) {
        super.onUpdate(dt);
    }
}
